import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
import device from './modules/device'
import createVuexPersisted from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {},
  getters: {
    token: (state) => state.user.token
  },
  mutations: {},
  actions: {},
  modules: {
    user,
    device
  },
  plugins: [
    createVuexPersisted({
      reducer (val) {
        // 指定存储某个模块的数据
        return {
          user: val.user
        }
      }
    })
  ]
})
